package com.cmcc.example.face.common.vo;

import lombok.Data;
import org.springframework.http.HttpStatus;

/**
 * <p>
 * <name>ResultVO</name>
 * 返回前端的传输对象
 * </p >
 *
 * @author arabira
 * @version 1.0 2020-04-01
 * @since 1.0
 */
@Data
public class ResultVO extends BaseVO{
    private String error;

    public static ResultVO success(Object data) {
        ResultVO result = new ResultVO();
        result.setCode(HttpStatus.OK.value());
        result.setMessage(HttpStatus.OK.getReasonPhrase());
        result.setData(data);
        return result;
    }

    public static ResultVO note(int code, String message, String error, Object data) {
        ResultVO result = new ResultVO();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        result.setError(error);
        return result;
    }

    public static ResultVO note(int code, String message, String error) {
        return note(code, message, error,null);
    }

    public static ResultVO serverError(String error) {
        ResultVO result = new ResultVO();
        result.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
        result.setMessage(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
        result.setError(error);
        return result;
    }
}